package 读书;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int N = 100010;
    static boolean[] p = new boolean[N];
    static int[] r = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        for (int cases = 1; cases <= T; cases++) {
            Arrays.fill(p, false);
            Arrays.fill(r, 0);
            int n = in.nextInt();
            int m = in.nextInt();
            int q = in.nextInt();
            for (int i = 0; i < m; i++) {
                int x = in.nextInt();
                p[x] = true;
            }
            for (int i = 0; i < q; i++) {
                int x = in.nextInt();
                r[x]++;
            }
            long res = 0;
            for (int i = 1; i <= n; i++) {
                if (r[i] > 0) {
                    for (int j = i; j <= n; j += i) {
                        if (!p[j]) {
                            res += r[i];
                        }
                    }
                }
            }
            System.out.printf("Case #%d: %d\n", cases, res);
        }
    }
}
